package com.jiguangssp.addemo.act;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.os.Bundle;
import android.util.Log;

import com.jiguangssp.addemo.R;
import com.jiguangssp.addemo.util.Constants;

import java.util.Map;

import xyz.adscope.amps.ad.reward.AMPSRewardVideoAd;
import xyz.adscope.amps.ad.reward.AMPSRewardVideoLoadEventListener;
import xyz.adscope.amps.common.AMPSError;
import xyz.adscope.amps.config.AMPSRequestParameters;

public class RewardActivity extends BaseAdActivity {

    ConstraintLayout constraintRoot;
    AMPSRewardVideoAd ampsRewardVideoAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reward);
        constraintRoot = findViewById(R.id.constraint_act_reward);
        loadAd();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (ampsRewardVideoAd != null) {
            ampsRewardVideoAd.destroy();
            ampsRewardVideoAd = null;
        }
    }

    @Override
    public void loadAd() {
        super.loadAd();
        AMPSRequestParameters parameter = new AMPSRequestParameters.Builder()
                .setSpaceId(Constants.JG_PUB_SPACE_ID_REWARDVIDEO)//激励视频广告位id
                .setTimeOut(Constants.JG_PUB_TIME_OUT)//超时时间
                .setAdCount(1)//设置请求广告条数
                .build();
        ampsRewardVideoAd = new AMPSRewardVideoAd(this, parameter, new AMPSRewardVideoLoadEventListener() {
            @Override
            public void onAmpsAdLoad() {
                Log.e(TAG, "onAmpsAdLoad: " );
                ampsRewardVideoAd.show(RewardActivity.this);
            }

            @Override
            public void onAmpsAdCached() {
                Log.e(TAG, "onAmpsAdCached: " );
            }

            @Override
            public void onAmpsAdFailed(AMPSError ampsError) {
                Log.e(TAG, "onAmpsAdFailed: " );
            }

            @Override
            public void onAmpsAdShow() {
                Log.e(TAG, "onAmpsAdShow: " );
            }

            @Override
            public void onAmpsAdDismiss() {
                Log.e(TAG, "onAmpsAdDismiss: " );
            }

            @Override
            public void onAmpsAdVideoClick() {
                Log.e(TAG, "onAmpsAdVideoClick: " );
            }

            @Override
            public void onAmpsAdVideoComplete() {
                Log.e(TAG, "onAmpsAdVideoComplete: " );
            }

            @Override
            public void onAmpsAdVideoError() {
                Log.e(TAG, "onAmpsAdVideoError: " );
            }

            @Override
            public void onAmpsAdRewardArrived(boolean b, int i, Map<String, Object> map) {
                Log.e(TAG, "onAmpsAdRewardArrived: " );
            }
        });
        ampsRewardVideoAd.loadAd();


    }
}